'use strict';
const pathExists = require('path-exists').sync;
const fse = require('fs-extra')
const path = require('path')
const log = require('@liangshaojie/log')

module.exports = clean;

function clean(args) {
    if (args.all) {
        if (pathExists(process.env.CLI_HOME_PATH)) {
            fse.emptyDirSync(process.env.CLI_HOME_PATH);
            log.success('清空全部缓存文件成功', process.env.CLI_HOME_PATH);
        } else {
            log.success('文件夹不存在222');
        }
    } else {
        const depPath = path.resolve(process.env.CLI_HOME_PATH, process.env.DEPENDENCIES_DIR);
        if (pathExists(depPath)) {
            fse.emptyDirSync(depPath);
            log.success('清空依赖文件成功', depPath);
        } else {
            log.success('文件夹不存在');
        }
    }
}
